#include"processbar.h"
#include<time.h>
#include<unistd.h>

#define FILESIZE 1024*1024*1024

void download(callback_t cb)
{
    srand(time(NULL)^2024);
    int total = FILESIZE;
    while(total)
    {
        usleep(50000); //下载动作
        int one = rand()%(1024*1024*10);
        total-=one;
        if(total<0) total = 0;

        int download = FILESIZE-total;
        double rate = (download*1.0/(FILESIZE))*100;
        //printf("%d\n",rate);
        cb(rate);
    }
}

int main()
{
    download(process_flush);
    //process();
    return 0;
}
